#include "../include/threadsafe_stack.h"

threadsafe_stack<int> stack;

void add_data() {
    for (int i = 0; i < 1000000; i++) {
        stack.push(i);
    }
}

void del_data() {
    for (int i = 0; i < 1000000; i++) {
        stack.pop();
    }
}

int main(int argc, char* argv[]) {
    std::thread t1(add_data);
    std::thread t2(add_data);
    t1.join();
    t2.join();

    std::cout << stack.size() << std::endl;
    t1 = std::thread(del_data);
    t2 = std::thread(del_data);
    t1.join();
    t2.join();

    std::cout << stack.size() << std::endl;

    // int value;
    // stack.pop(value);
    // terminate called after throwing an instance of 'empty_stack'
    // what():  try to pop from empty stack
    // Aborted (core dumped)

    return 0;
}

